package Homework;
//用户输入整数n，计算1!+(1!+2!)+(1!+2!+3!)+…..+(1!+2!+…n!)
//用方法实现
//有参数有返回值
import java.util.Scanner;
public class test29 {
    public static void main(String[] args) {
        Scanner SC=new Scanner(System.in);
        System.out.println("请输入n的值：");
        int n =SC.nextInt();
        System.out.println(getmath( n));
    }
    public static  int getmath(int n) {
    int sum =1;
    if(n < 0){
        System.out.println("负数没有阶层！");
    }else if (n==1||n==0){
        System.out.println(n +"的阶层为1");
    }else{
        for(int i =0;i<n;i++){
            sum +=i;
        }return sum;
    }return sum;
    }
}
